//
//  StatusRetweetedFrame.m
//  CC
//
//  Created by Calvin on 5/18/15.
//  Copyright (c) 2015 Calvin. All rights reserved.
//

#import "StatusRetweetedFrame.h"
#import "StatusModel.h"
#import "UserModel.h"
#import "StatusCell.h"

@implementation StatusRetweetedFrame
-(void)setRetweeted_status:(StatusModel *)retweeted_status
{
    _retweeted_status =retweeted_status;
    //Calculate nickname frame
    CGFloat nameX = CellStatusInset;
    CGFloat nameY = CellStatusInset;
//    CGSize nameSize = [retweeted_status.user.name sizeWithFont:StatusRetweetedNameFont];
    CGSize nameSize = [retweeted_status.user.name sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:StatusRetweetedNameFont,StatusRetweetedNameFont.fontName,nil]];
    self.nameFrame = CGRectMake(nameX, nameY, nameSize.width, nameSize.height);
    
    //Calculate text frame
    CGFloat textX = nameX;
    CGFloat textY = CGRectGetMaxY(self.nameFrame) + CellStatusInset;
    CGFloat screenW = ScreenW;
    CGFloat margin = 2*CellStatusInset;
    CGFloat maxW = screenW - margin;
     CGSize maxSize=CGSizeMake(maxW, MAXFLOAT);
    CGSize textSize = [retweeted_status.text sizeWithFont:StatusRetweetedNameFont constrainedToSize:maxSize];
//    CGSize textSize = [retweeted_status.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:StatusRetweetedNameFont,StatusRetweetedNameFont.fontName, nil]];
    self.textFrame = CGRectMake(textX, textY, textSize.width, textSize.height);
    
    //Calculate self frame
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat w = ScreenW;
    CGFloat h = CGRectGetMaxY(self.textFrame) + CellStatusInset;
    self.frame = CGRectMake(x, y, w, h);
}
@end
